home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 054a / cismnav.zip / CISMNAV.WAS < prev    next >
Text File  |  1993-02-19  |  8KB  |  179 lines

  1. ;******************************************************************************
  2. ;*   SCRIPT:                       CISMNAV.WAS
  3. ;*   AUTHOR:                       Philip Troiano
  4. ;*   Date:                         3/1/93
  5. ;*   Cis #:                        76046,2003
  6. ;*
  7. ;*   Purpose:  To download CIS data directly into an Excel spread sheet.
  8. ;*   This script is called by an Excel Macro.  It takes a list of ticker
  9. ;*   symbols from an Excel spreadsheet (mthlynav.xls) and feeds them to
  10. ;*   CompuServe's MQINT interface.  It takes the data received and writes it
  11. ;*   to another spreadsheet (tempdata.xls).
  12. ;*
  13. ;*   The Excel macro then takes the data, parses it, calculates min & end of
  14. ;*   month NAV's and then fills in my monthly price summary sheet.
  15. ;*
  16. ;*   It should have been uploaded with a copy of the associated Excel Macro
  17. ;*   CISMNAV.XLM.
  18. ;*
  19. ;*   If any can use any part of this, GOOD!  If it even helps someone think of
  20. ;*   a different solution to one of their problems, thats even better.
  21. ;*
  22. ;*   Replace the xxxxxxxxx at the end of the logon script with password and
  23. ;*   user ID.  The log on script looks for "compuserve" in the Prowin Dialing
  24. ;*   Directory, so make sure you have created an entry with that string in the
  25. ;*   NAME field.
  26. ;*
  27. ;*;******************************************************************************
  28.  
  29. long ddechan = 0
  30. long ddechan1 = 0
  31. long ddemacr = 0
  32. string cellref
  33. string echocr
  34. string echodata
  35. string mds
  36. string pokecellref
  37. string returndata
  38. string ticksymb
  39. string transtickstring
  40.  
  41. PROC MAIN
  42.  
  43. set aspect rxdata off
  44.  
  45.         call XCL_LINK
  46.         call LOGON_MQINT
  47.         call TRANSMIT_DATA
  48.  
  49. pause 10
  50.  
  51. ddeterminate ddechan                                                    ;terminates link to mthlynav.xls
  52. ddeterminate ddechan1                                                   ;terminates link to tempdata.xls
  53.  
  54. activatewin "Microsoft Excel - TEMPDATA.XLS"                    ;activates excel
  55. sendkey CTRL 0x5A                                                                       ;sends ctrl-z to activate CisMAcroEnd
  56.  
  57. ddeterminate ddemacr                                                    ;terminates link to cismnav.xlm
  58.  
  59. endproc
  60. ;---------------------------------------------------------------------------------------
  61. PROC XCL_LINK
  62.  
  63. ddeinit ddechan "excel" "[newmutnv.xlw]mthlynav.xls"            ; Try to initiate DDE link with xcl sheet
  64.         if ddechan == 0                         ; If no link established
  65.            usermsg "Unable to establish a link to Mthlynav.xls"
  66.         endif
  67. ddeinit ddechan1 "excel" "tempdata.xls"         ; Try to initiate DDE link with xcl sheet
  68.         if ddechan1 == 0                        ; If no link established
  69.            usermsg "Unable to establish a link to Tempdata.xls"
  70.         endif
  71. ddeinit ddemacr "excel" "[newmutnv.xlw]cismnav.xlm"             ; Try to initiate DDE link with xcl macro
  72.         if ddemacr == 0                         ; If no link established
  73.            usermsg "Unable to establish a link to cismnav.xlm"
  74.         endif
  75. dderequest ddemacr "monthdatastring" mds        ;requests the requested months data string
  76. strcpy mds mds 16                               ;strips trailing characters from the mds var
  77.  
  78. endproc
  79. ;---------------------------------------------------------------------------------------
  80. PROC TRANSMIT_DATA
  81. i0=2                                                                                                                    ; first row of data is row 3 so set to 2 to increment
  82. i3=0                                                                                                                    ;sets row counter for the ddepoke cellref
  83.  
  84. GETNEWSYMBOL:
  85. i0++
  86. i3++
  87.  
  88. strfmt cellref "R%iC4" i0                                       ;forms the string to get the cell with the next ticker
  89. dderequest ddechan cellref s0                   ;gets serial ticker symbols
  90. strlen s0 i1                                                                                    ;gets the length of the returned text(5 letters got 7)
  91. i2=i1-2                                                                                                         ;the difference in the actual letters and recv'd data
  92. strcpy ticksymb s0 i2                                                   ;puts only tick symbols into variable
  93. strfmt transtickstring "%s%s^M" ticksymb mds            ;formats the trasmit string
  94.  
  95. s2 = "cont"                                                                                             ;tests for cont. and jumps script to the index symbols
  96. strcmpi s0 s2 4                                                                         ;compares the xcl cell less CR to "END : quits if true
  97. if success
  98.   i3--
  99.         goto GETNEWSYMBOL
  100. endif
  101.  
  102. s1 = "END"                                                                                              ;tests for the end of the ticker symbol column
  103. strcmpi s0 s1 3                                                                         ;compares the xcl cell less CR to "END : quits if true
  104. if success
  105.   goto LASTSYMBOL
  106. else
  107.   waitfor ":" 2
  108.         transmit transtickstring
  109.                 statmsg "transmitstring=%s" transtickstring
  110.   set aspect rxdata on                                          ; tells script to process incoming data
  111.         rget echodata                                                                           ;captures the echoed transmit string
  112.         rget echocr 1                                                                           ; captures an echoed CR
  113.         rget returndata                                                                 ;captures the incoming price data
  114.   strfmt pokecellref "R%iC1" i3         ; formats the next xcl cellref for ticker symbols
  115.   ddepoke ddechan1 pokecellref ticksymb         ;writes the ticker symbols to xcl
  116.   strfmt pokecellref "R%iC2" i3                 ; formats the next xcl cellref
  117.   ddepoke ddechan1 pokecellref returndata               ;writes the contents of rtd to xcl
  118.                 statmsg "Data for %s is %s" ticksymb returndata
  119.   set aspect rxdata off
  120.         if not success
  121.           usermsg "ddepoke not successful"
  122.           goto LASTSYMBOL
  123.         else
  124.         endif
  125.   goto GETNEWSYMBOL
  126. endif
  127.  
  128. LASTSYMBOL:
  129.  
  130. transmit "^M"                                                                                   ;logs off MQINT and CIS
  131. waitfor "Interface:"
  132. transmit "^M"
  133. waitfor "!"
  134. transmit "Bye ^M"
  135.  
  136. endproc
  137. ;---------------------------------------------------------------------------------------
  138. proc LOGON_MQINT
  139.  
  140. integer ent
  141.         while $TXCOUNT
  142.         endwhile
  143.  
  144. if ! $FROMDDIR
  145.         set terminal type 25
  146.         set port parity even
  147.         set port databits 7
  148.         set port stopbits 1
  149.         set protocol CISB
  150.         dialfind "CompuServe" ent
  151.         if found
  152.                 dial ent
  153.         else
  154.     usermsg "CompuServe not found in this dialing directory"
  155.   endif
  156. endif
  157. while $DIALING
  158. endwhile
  159. pause 1
  160. if $CARRIER
  161.   transmit "^C"
  162.   waitfor "User ID:" 15
  163.   transmit "xxxxxxxxxxx"
  164.   transmit "^M"
  165.   waitfor "Password:" 15
  166.   transmit xxxxxxxxxxx"
  167.   transmit "^M"
  168.   waitfor "!" 60
  169.   set terminal enquiry cisb
  170.   endif
  171.  
  172. transmit "GO MQINT ^M"               ; MQINT accessed in this next section
  173. waitfor "Interface:" 20
  174. pause 1
  175. transmit "200 ^M"                    ; accesses Interface 200
  176.  
  177. endproc
  178. ;---------------------------------------------------------------------------------------
  179.